//
//  cellViewController.m
//  refreshTest
//
//  Created by boc on 15/11/20.
//  Copyright © 2015年 bocweb. All rights reserved.
//

#import "cellViewController.h"
#import "SDWebImageManager.h"
#import <SDWebImage/UIImageView+WebCache.h>
@interface cellViewController ()<SDWebImageManagerDelegate>
@property (strong ,nonatomic) SDWebImageManager *manager;
@end

@implementation cellViewController
//-(BOOL)imageManager:(SDWebImageManager *)imageManager shouldDownloadImageForURL:(NSURL *)imageURL
//{
//    return YES;
//}
- (void)viewDidLoad
{
    [super viewDidLoad];
    _manager = [SDWebImageManager sharedManager];
    img = [[UIImageView alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
    img.contentMode = UIViewContentModeScaleAspectFit;
    _manager.delegate =self;
    [self.view addSubview:img];
    [_manager downloadImageWithURL:[NSURL URLWithString:@"http://img4.paipaiimg.com/da2b708f/item-00AA562A-0C11960600000000040100001B271664.0.300x300.jpg"] options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) {
        NSLog(@"downloading");
    }  completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
        

        img.image = image;
    }];
     
    
    self.title = @"测试控制器";
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"关闭" style:UIBarButtonItemStyleDone target:self action:@selector(close)];

}

- (void)close
{
    if (self.presentingViewController) {
        [self dismissViewControllerAnimated:YES completion:nil];
    } else {
        [self.navigationController popViewControllerAnimated:YES];
    }
}
@end
